import java.util.Arrays;
import java.util.Comparator;

public class LambdaTest {
    public static void main(String[] args) {

        Integer[] arr = {2, 3, 1, 5, 6, 7, 8, 4, 9};

        Arrays.sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;//正序
            }
        });
        System.out.println(Arrays.toString(arr));//数组变字符串


        System.out.println("----------------------------------");


        //lambda完整格式
        Arrays.sort(arr, (Integer o1, Integer o2) -> {
                    return o1 - o2;//正序
                }
        );
        System.out.println(Arrays.toString(arr));//数组变字符串


        System.out.println("----------------------------------");


        //lambda省略写法
        Arrays.sort(arr, (o1, o2) -> o2 - o1);//倒序
        System.out.println(Arrays.toString(arr));//数组变字符串

    }
}
